; Music of Sorcery (1985) (Virgin Games)
; Ripped by Megachur the 25/10/2006

	write "SORCERY.BIN"

music_date_rip	equ &19a6
music_adr	equ &2298
first_theme	equ 0
last_theme	equ 0

	read "music_header_v1_0.asm"

	db #00

	ld a,(l2313)
	sub #01
	jr c,l22a5
	ld (l2313),a
	jr l22c2
.l22a5
	ld hl,(l230e)
	ld a,(hl)
	cp #ff
	jr z,l22c2
	ld (l2313),a
	inc hl
	ld e,(hl)
	ld a,#06
	call l22f1
	inc hl
	ld e,(hl)
	ld a,#08
	call l22f1
	inc hl
	ld (l230e),hl
.l22c2
	ld a,(l2314)
	sub #01
	jr c,l22cd
	ld (l2314),a
	ret
.l22cd
	ld hl,(l2310)
	ld a,(hl)
	cp #ff
	ret z
	ld (l2314),a
	inc hl
	ld a,#02
	ld e,(hl)
	call l22f1
	inc hl
	ld a,#03
	ld e,(hl)
	call l22f1
	inc hl
	ld a,#09
	ld e,(hl)
	call l22f1
	inc hl
	ld (l2310),hl
	ret
.l22f1
	push bc
	ld b,#f4
	out (c),a
	ld b,#f6
	ld a,#c0
	out (c),a
	xor a
	out (c),a
	ld b,#f4
	out (c),e
	ld b,#f6
	ld c,a
	or #80
	out (c),a
	out (c),c
	pop bc
	ret
.l230e
	dw l2312
.l2310
	dw l2312
.l2312
	db #ff
.l2313
	db #00
.l2314
	db #00,#00,#05,#02,#00,#05,#04,#00
	db #05,#06,#01,#05,#08,#01,#04,#0a
	db #00,#04,#0c,#00,#04,#0e,#02,#03
	db #0f,#05,#03,#0e,#06,#02,#0c,#08
	db #02,#0a,#08,#01,#08,#09,#01,#06
	db #09,#00,#04,#09,#00,#02,#00,#00
	db #00,#ff,#05,#00,#0f,#05,#03,#0e
	db #05,#05,#0d,#05,#08,#0b,#04,#0c
	db #0a,#04,#11,#09,#04,#18,#07,#03
	db #1d,#06,#03,#1b,#05,#02,#1c,#04
	db #02,#1d,#03,#02,#1e,#02,#01,#1f
	db #01,#00,#00,#00,#ff,#01,#14,#0a
	db #01,#12,#0b,#01,#0f,#0c,#02,#0c
	db #0d,#02,#09,#0e,#02,#06,#0c,#02
	db #04,#09,#03,#02,#05,#00,#00,#00
	db #ff,#01,#00,#0d,#0f,#01,#00,#0c
	db #0f,#01,#00,#0b,#0f,#01,#00,#0a
	db #0f,#01,#00,#09,#0f,#01,#00,#08
	db #0f,#01,#00,#07,#0f,#01,#00,#06
	db #0f,#01,#00,#05,#0f,#01,#00,#04
	db #0f,#00,#00,#00,#00,#ff,#01,#00
	db #03,#0f,#01,#00,#04,#0f,#01,#00
	db #05,#0f,#01,#00,#06,#0f,#01,#00
	db #07,#0f,#01,#00,#08,#0f,#01,#00
	db #09,#0f,#01,#00,#0b,#0f,#01,#00
	db #0d,#0f,#01,#00,#0f,#0f,#00,#00
	db #00,#00,#ff,#01,#00,#04,#0f,#01
	db #96,#03,#0f,#01,#32,#03,#0f,#00
	db #c8,#02,#0f,#00,#64,#02,#0f,#00
	db #c8,#01,#0f,#00,#32,#01,#0f,#00
	db #00,#00,#00,#ff,#00,#00,#0c,#0f
	db #00,#00,#00,#00,#ff
;
.init_music
.l2411
;
	ld hl,l2572
	ld (l27bb),hl
	ld hl,l25f4
	ld (l27be),hl
	ld hl,l2736
	ld (l27c1),hl
	ld a,#01
	ld (l27ba),a
	ld (l27bd),a
	ld (l27c0),a
	ld a,#07
	ld e,#38
	call l22f1
	ret
;
.play_music
.l2436
;
	push ix
	ld c,#00
	ld ix,l27ba
	call l2460
	pop ix
	nop     	;	ret deleted by Megachur
	push ix
	ld c,#01
	ld ix,l27bd
	call l2460
	pop ix
	nop     	;	ret deleted by Megachur
	push ix
	ld c,#02
	ld ix,l27c0
	call l2460
	pop ix
	ret
.l2460
	dec (ix+#00)
	ret nz
	ld l,(ix+#01)
	ld h,(ix+#02)
	ld e,(hl)
	inc hl
	ld d,(hl)
	inc hl
	ld (ix+#01),l
	ld (ix+#02),h
	ld (ix+#00),d
	bit 7,e
	jr z,l248d
	ld a,e
	cp #80
	jr nz,l2489
	ld a,c
	add #08
	ld e,#00
	call l22f1
	ret
.l2489
	call l2411      ; init music when end
	ret
.l248d
	ld b,c
	sla c
	ld hl,l24b2
	ld d,#00
	add hl,de
	add hl,de
	ld a,c
	ld e,(hl)
	call l22f1
	ld a,c
	inc a
	inc hl
	ld e,(hl)
	call l22f1
	ld a,b
	add #08
	ld hl,l27c3
	ld c,b
	ld b,#00
	add hl,bc
	ld e,(hl)
	call l22f1
	ret
.l24b2
	dw #0eee,#0e18,#0d4d,#0c8e
	dw #0bda,#0b2f,#0a8f,#09f7
	dw #0968,#08e1,#0861,#07e9
	dw #0777,#070c,#06a7,#0647
	dw #05ed,#0598,#0547,#04fc
	dw #04b4,#0470,#0431,#03f4
	dw #03bc,#0386,#0353,#0324
	dw #02f6,#02cc,#02a4,#027e
	dw #025a,#0238,#0218,#01fa
	dw #01de,#01c3,#01aa,#0192
	dw #017b,#0166,#0152,#013f
	dw #012d,#011c,#010c,#00fd
	dw #00ef,#00e1,#00d5,#00c9
	dw #00be,#00b3,#00a9,#009f
	dw #0096,#008e,#0086,#007f
	dw #0077,#0071,#006a,#0064
	dw #005f,#0059,#0054,#0050
	dw #004b,#0047,#0043,#003f
	dw #003c,#0038,#0035,#0032
	dw #002f,#002d,#002a,#0028
	dw #0026,#0024,#0022,#0020
	dw #001e,#001c,#001b,#0019
	dw #0018,#0016,#0015,#0014
	dw #0013,#0012,#0011,#0010
.l2572
	db #2b,#08,#2d,#08,#2f,#08,#30,#10
	db #33,#08,#30,#10,#33,#08,#32,#08
	db #30,#08,#2f,#08,#30,#10,#33,#08
	db #30,#10,#33,#08,#32,#08,#30,#08
	db #2f,#08,#30,#10,#33,#08,#30,#08
	db #33,#08,#32,#08,#30,#08,#32,#08
	db #33,#08,#32,#08,#35,#08,#33,#08
	db #32,#10,#38,#08,#30,#10,#33,#08
	db #32,#08,#35,#08,#33,#08,#32,#10
	db #38,#08,#30,#10,#33,#08,#34,#08
	db #37,#08,#36,#08,#34,#18,#34,#08
	db #36,#08,#37,#08,#38,#08,#3b,#08
	db #39,#08,#37,#18,#38,#08,#39,#08
	db #3a,#08,#3b,#08,#3e,#08,#3c,#08
	db #3b,#18,#3b,#08,#3c,#08,#3d,#08
	db #3e,#08,#42,#08,#40,#08,#3e,#10
	db #ff,#ff
.l25f4
	db #47,#04,#3b,#04,#46,#04,#3a,#04
	db #45,#04,#39,#04,#50,#04,#44,#04
	db #4f,#04,#43,#04,#4e,#04,#42,#04
	db #4d,#04,#41,#04,#4c,#04,#40,#04
	db #4b,#04,#3f,#04,#4d,#04,#41,#04
	db #4e,#04,#42,#04,#4f,#04,#43,#04
	db #50,#04,#44,#04,#4f,#04,#43,#04
	db #4e,#04,#42,#04,#4d,#04,#41,#04
	db #4c,#04,#40,#04,#4b,#04,#3f,#04
	db #4d,#04,#41,#04,#4e,#04,#42,#04
	db #4f,#04,#43,#04,#50,#04,#44,#04
	db #4f,#04,#43,#04,#50,#04,#44,#04
	db #51,#04,#45,#04,#52,#04,#46,#04
	db #53,#04,#47,#04,#54,#04,#48,#04
	db #52,#04,#46,#04,#51,#04,#45,#04
	db #50,#04,#44,#04,#4f,#04,#43,#04
	db #4e,#04,#42,#04,#4d,#04,#41,#04
	db #4c,#04,#40,#04,#4b,#04,#3f,#04
	db #4a,#04,#3e,#04,#49,#04,#3d,#04
	db #48,#04,#3c,#04,#50,#04,#44,#04
	db #4f,#04,#43,#04,#4e,#04,#38,#04
	db #4d,#04,#41,#04,#4c,#04,#40,#04
	db #4b,#04,#3f,#04,#4a,#04,#3e,#04
	db #49,#04,#3d,#04,#48,#04,#3c,#04
	db #46,#04,#3a,#04,#47,#04,#3b,#04
	db #48,#04,#3c,#04,#49,#04,#3d,#04
	db #4a,#04,#3e,#04,#4b,#04,#3f,#04
	db #4d,#04,#41,#04,#4c,#04,#40,#04
	db #4b,#04,#3f,#04,#4a,#04,#3e,#04
	db #4b,#04,#3f,#04,#4c,#04,#40,#04
	db #4d,#04,#41,#04,#4e,#04,#42,#04
	db #4f,#04,#43,#04,#51,#04,#45,#04
	db #50,#04,#44,#04,#4f,#04,#43,#04
	db #4d,#04,#41,#04,#4e,#04,#42,#04
	db #4f,#04,#43,#04,#50,#04,#44,#04
	db #52,#04,#46,#04,#53,#04,#47,#04
	db #54,#04,#48,#04,#53,#04,#47,#04
	db #52,#04,#46,#04,#45,#04,#39,#04
	db #46,#04,#3a,#04,#48,#04,#3c,#04
	db #49,#04,#3d,#04,#4a,#04,#3e,#04
	db #ff,#ff
.l2736
	db #2b,#04,#2d,#08,#2f,#08,#30,#10
	db #33,#08,#30,#10,#33,#08,#32,#08
	db #30,#08,#2f,#08,#30,#10,#33,#08
	db #30,#10,#33,#08,#32,#08,#30,#08
	db #2f,#08,#30,#10,#33,#08,#30,#08
	db #33,#08,#32,#08,#30,#08,#32,#08
	db #33,#08,#32,#08,#35,#08,#33,#08
	db #32,#10,#38,#08,#30,#10,#33,#08
	db #32,#08,#35,#08,#33,#08,#32,#10
	db #38,#08,#30,#10,#33,#08,#34,#08
	db #37,#08,#36,#08,#34,#18,#34,#08
	db #36,#08,#37,#08,#38,#08,#3b,#08
	db #39,#08,#37,#18,#38,#08,#39,#08
	db #3a,#08,#3b,#08,#3e,#08,#3c,#08
	db #3b,#18,#3b,#08,#3c,#08,#3d,#08
	db #3e,#08,#42,#08,#40,#08,#3e,#10
	db #80,#04,#ff,#ff
.l27ba
	db #00
.l27bb
	db #00,#00
.l27bd
	db #00
.l27be
	db #00,#00
.l27c0
	db #00
.l27c1
	db #00,#00
.l27c3
	db #0f,#06,#0f,#00,#00,#00,#00,#00
	db #00,#00,#00

.game_name
	db "Sorcery",0
.game_year
	db "1985",0
.game_publisher
	db "Virgin Games",0
.music_author
	db "",0
.music_comment
	db "",0

	read "music_end_v1_0.asm"
